//
//  SDKBridgeUtil.m
//  QySDKBridge
//
//  Created by lcc on 2025/2/10.
//

#import "SDKBridgeUtil.h"
#import "UnityInterface.h"
#import "SDKBridgeConstant.h"
@implementation SDKBridgeUtil


// 向 Unity 发送消息
+ (void)SendMsgToUnity:(NSString *)funcName msg:(NSString *)msg{
    UnitySendMessage([UnityReceiverObjName UTF8String], [funcName UTF8String], [msg UTF8String]);
}


// json 变成字典
+ (NSDictionary *)JsonToDict:(NSString *)jsonStr{
    NSData * getJsonData = [jsonStr dataUsingEncoding:NSUTF8StringEncoding];
    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:getJsonData options:NSJSONReadingAllowFragments error:nil];
    return dict;
}

// json 变数组
+ (NSMutableArray *)JsonToArray:(NSString *)jsonStr{
    NSData * getJsonData = [jsonStr dataUsingEncoding:NSUTF8StringEncoding];
    NSMutableArray *array = [NSJSONSerialization JSONObjectWithData:getJsonData options:NSJSONReadingAllowFragments error:nil];
    return array;
}

+ (NSString *)ObjectToJson:(NSObject *)object{
    NSData * data = [NSJSONSerialization dataWithJSONObject:object options:NSJSONWritingPrettyPrinted error:nil];
    NSString * json = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
    
    return json;
}

@end
